<template>
    <div class="pannel-wrapper">
        <div class="pannel">
            <div class="pannel-title">小程序常用链接</div>
            <Form ref="formValidate" label-position="left" :label-width="110" class="form-wrapper">
                <FormItem label="小程序主页">
                    <Input id="mainpathInput" v-model="mainpath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="mainpBtn" type="primary" data-clipboard-target="#mainpathInput" @click="copyUrl('.mainpBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="发现页">
                    <Input id="discoverInput" v-model="discoverpath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="discoverBtn" type="primary" data-clipboard-target="#discoverInput" @click="copyUrl('.discoverBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="尝鲜页">
                    <Input id="testnewInput" v-model="testnewpath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="testnewBtn" type="primary" data-clipboard-target="#testnewInput" @click="copyUrl('.testnewBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="9块9页面">
                    <Input id="nineInput" v-model="ninepath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="nineBtn" type="primary" data-clipboard-target="#nineInput" @click="copyUrl('.nineBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="我的页面">
                    <Input id="mineInput" v-model="minepath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="mineBtn" type="primary" data-clipboard-target="#mineInput" @click="copyUrl('.mineBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="我的订单页面">
                    <Input id="orderInput" v-model="orderpath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="orderBtn" type="primary" data-clipboard-target="#orderInput" @click="copyUrl('.orderBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="企业助手">
                    <Input id="shopInput" v-model="shoppath" readonly style="width: 320px; margin-right: 15px;"></Input>
                    <Button class="shopBtn" type="primary" data-clipboard-target="#shopInput" @click="copyUrl('.shopBtn')">点击复制</Button>
                </FormItem>
                <FormItem label="商品详情路径">
                    <Input v-model="shopdetailpath" readonly style="width: 320px; margin-right: 15px;"></Input>
                </FormItem>
                <FormItem label="微页面路径">
                    <Input v-model="micropagepath" readonly style="width: 320px; margin-right: 15px;"></Input>
                </FormItem>
            </Form>
        </div>
    </div>
</template>

<script>

import Clipboard from 'clipboard'

export default {
    data () {
        return {
            mainpath: 'app/mallA/index/index',
            discoverpath: 'app/mallA/discoverEntrance/discoverEntrance',
            testnewpath: 'app/mallA/discoverEntrance/discoverEntrance',
            ninepath: 'app/mallA/discoverEntrance/discoverEntrance',
            minepath: 'app/personA/index/index',
            orderpath: 'app/person/order/order',
            shoppath: 'app/common/webview/webview?url=offCode.html',
            shopdetailpath: '在左侧商品点击商品编辑，左侧二维码有商品路径',
            micropagepath: '在左侧商城装修下面有微页面，点击进去有微页面路径',
        }
    },
    methods: {
        // 复制链接
        copyUrl(btnclass){
            let clipboard = new Clipboard(btnclass);
            clipboard.on('success', e => {
                this.$Message.success('复制成功！')
                clipboard.destroy()
            })
            clipboard.on('error', e => {
                this.$Message.error('复制失败，请更换浏览器或者手动复制')
                clipboard.destroy()
            })
        },
    }
}
</script>

<style scoped>
.pannel-wrapper {
    /*padding: 12px 20px 12px 12px;*/
    height: calc(100vh - 112px);
}
.pannel {
    background: white;
    height: 100%;
    overflow: auto;
}
.pannel-title {
    font-size: 14px;
    padding: 18px;
    border: 1px solid #eeeeee;
}
.form-wrapper {
    padding: 24px;
}

</style>
